//
//  GetHeightTools.m
//  UI_12自定义cell的行高
//
//  Created by dllo on 16/6/22.
//  Copyright © 2016年 WYW. All rights reserved.
//

#import "GetHeightTools.h"

@implementation GetHeightTools
+ (CGFloat)heightWith:(NSString *)text
{
    NSDictionary *dictionary = @{NSFontAttributeName: [UIFont systemFontOfSize:17]};
    CGRect rect = [text boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dictionary context:nil];
    
   // ceilf() 取整函数
    return  ceilf(rect.size.height);//返回计算出来的行高
}
+(CGFloat)imageHeightWith:(NSString *)imageName
{
    UIImage *image = [UIImage imageNamed:imageName];
    
    //根据图片的宽度比例算出自适应高度
    CGFloat height = (image.size.height * [UIScreen mainScreen].bounds.size.width) / image.size.width;
    
    return height;
}
@end

